<template>
  <van-button v-if="order.status !== 3" class="out" round plain @click="onCancelOrder()"
    >取消问诊</van-button
  >
  <van-button v-if="order.prescriptionId" class="out" round plain @click="CheckPre"
    >查看处方</van-button
  >
  <van-button class="next" round plain type="success" @click="$router.push({path:'/room',query:{orderId:order.id}})">继续沟通</van-button>
</template>

<script setup>
import { defineEmits, defineProps } from 'vue'
import { referPrescription } from '@/api'
import { showImagePreview } from 'vant'

const emits = defineEmits(['cancelOrder'])
const props = defineProps({
  order: {
    type: Object,
    default: () => {}
  }
})

// 取消问诊
const onCancelOrder = () => {
  emits('cancelOrder')
}

// 查看处方
const CheckPre = async () => {
  const { data } = await referPrescription(props.order.prescriptionId)
  showImagePreview([data.url])
}
</script>

<style lang="scss" scoped></style>
